package com.zyh.homework.test5;

import java.util.ArrayList;

/**
 * @Author zyh
 * @Date 2024/7/29
 * @Description 1.定义ArrayList集合，存入多个字符串
 * 		           如:"ab1" "123ad"  "bca" "dadfadf"  "dddaaa"  "你好啊"  "我来啦"  "别跑啊"
 * 		        2.遍历集合,删除长度大于5的字符串,打印删除后的集合对象
 * 		        3.基于上一步,删除集合中元素包含0-9数字的字符串(只要字符串中包含0-9中的任意一个数字就需要删除此整个字符串)
 */
public class Test5 {
    public static void main(String[] args) {
        ArrayList<String> list=new ArrayList<>();
        list.add(new String("ab1"));
        list.add(new String("123ad"));
        list.add(new String("bcaqwerty"));
        list.add(new String("dadfadfqe"));
        list.add(new String("dddaaaqwer"));
        list.add(new String("你好啊1111"));
        list.add(new String("我来啦"));
        list.add(new String("别跑啊"));
        for (int i = 0; i < list.size(); i++) {
            String s = list.get(i);
            if (s.length()>5){
                list.remove(s);
                i-=1;
            }
        }
        System.out.println("list = " + list);
    }
}
